package com.kurancy.domain.enums;

import com.kurancy.domain.field.base.OptionPair;

/**
 * The Enum State.
 *
 * @author ttagge
 */
public enum State implements OptionPair {

	/** The AL. */
	AL(1, "Alabama", "AL"),
	
	/** The AK. */
	AK(2,"Alaska", "AK"),
	
	/** The AZ. */
	AZ(3,"Arizona", "AZ"),
	
	/** The AR. */
	AR(4,"Arkansas", "AR"),
	
	/** The CA. */
	CA(5,"California", "CA"),
	
	/** The CO. */
	CO(6,"Colorado", "CO"),
	
	/** The CT. */
	CT(7,"Connecticut", "CT"),
	
	/** The DE. */
	DE(8,"Delaware", "DE"),
	
	/** The DC. */
	DC(9,"District of Columbia", "DC"),
	
	/** The FL. */
	FL(10,"Florida", "FL"),
	
	/** The GA. */
	GA(11,"Georgia", "GA"),
	
	/** The HI. */
	HI(12,"Hawaii", "HI"),
	
	/** The ID. */
	ID(13,"Idaho", "ID"),
	
	/** The IL. */
	IL(14,"Illinois", "IL"),
	
	/** The IN. */
	IN(15,"Indiana", "IN"),
	
	/** The IA. */
	IA(16,"Iowa", "IA"),
	
	/** The KS. */
	KS(17,"Kansas", "KS"),
	
	/** The KY. */
	KY(18,"Kentucky", "KY"),
	
	/** The LA. */
	LA(19,"Louisiana", "LA"),
	
	/** The ME. */
	ME(20,"Maine", "ME"),
	
	/** The MD. */
	MD(21,"Maryland", "MD"),
	
	/** The MA. */
	MA(22,"Massachusetts", "MA"),
	
	/** The MI. */
	MI(23,"Michigan", "MI"),
	
	/** The MN. */
	MN(24,"Minnesota", "MN"),
	
	/** The MS. */
	MS(25,"Mississippi", "MS"),
	
	/** The MO. */
	MO(26,"Missouri", "MO"),
	
	/** The MT. */
	MT(27,"Montana", "MT"),
	
	/** The NE. */
	NE(28,"Nebraska", "NE"),
	
	/** The NV. */
	NV(29,"Nevada", "NV"),
	
	/** The NH. */
	NH(30,"New Hampshire", "NH"),
	
	/** The NJ. */
	NJ(31,"New Jersey", "NJ"),
	
	/** The NM. */
	NM(32,"New Mexico", "NM"),
	
	/** The NY. */
	NY(33,"New York", "NY"),
	
	/** The NC. */
	NC(34,"North Carolina", "NC"),
	
	/** The ND. */
	ND(35,"North Dakota", "ND"),
	
	/** The OH. */
	OH(36,"Ohio", "OH"),
	
	/** The OK. */
	OK(37,"Oklahoma", "OK"),
	
	/** The OR. */
	OR(38,"Oregon", "OR"),
	
	/** The PA. */
	PA(39,"Pennsylvania", "PA"),
	
	/** The RI. */
	RI(40,"Rhode Island", "RI"),
	
	/** The SC. */
	SC(41,"South Carolina", "SC"),
	
	/** The SD. */
	SD(42,"South Dakota", "SD"),
	
	/** The TN. */
	TN(43,"Tennessee", "TN"),
	
	/** The TX. */
	TX(44,"Texas", "TX"),
	
	/** The UT. */
	UT(45,"Utah", "UT"),
	
	/** The VT. */
	VT(46,"Vermont", "VT"),
	
	/** The VA. */
	VA(47,"Virginia", "VA"),
	
	/** The WA. */
	WA(48,"Washington", "WA"),
	
	/** The WV. */
	WV(49,"West Virginia", "WV"),
	
	/** The WI. */
	WI(50,"Wisconsin", "WI"),
	
	/** The WY. */
	WY(51,"Wyoming", "WY"),
	
	/** The PR. */
	PR(52,"Puerto Rico", "PR");
	
	/** The value. */
	private int value;
	
	/** The name. */
	private String name;
	
	/** The state abbreviation. */
	private String stateAbbreviation;
	
	/**
	 * Instantiates a new state.
	 *
	 * @param value the value
	 * @param name the name
	 * @param stateAbbreviation the state abbreviation
	 */
	private State(int value, String name, String stateAbbreviation) {
		this.value = value;
		this.name = name;
		this.stateAbbreviation = stateAbbreviation;
	}

	/**
	 * From id.
	 *
	 * @param id the id
	 * @return the state
	 */
	public static State fromId(Integer id) {
		if (id != null) {
			for (State state : State.values()) {
				if (id.equals(state.value)) {
					return state;
				}
			}	
		}
		return null;		
	}

	/* (non-Javadoc)
	 * @see com.bidclerk.commons.model.OptionPair#getValue()
	 */
	public Integer getValue() {
		return value;
	}

	/**
	 * Sets the value.
	 *
	 * @param value the new value
	 */
	public void setValue(int value) {
		this.value = value;
	}

	/* (non-Javadoc)
	 * @see com.bidclerk.commons.model.OptionPair#getName()
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the name.
	 *
	 * @param name the new name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the state abbreviation.
	 *
	 * @return the state abbreviation
	 */
	public String getStateAbbreviation() {
		return stateAbbreviation;
	}

	/**
	 * Sets the state abbreviation.
	 *
	 * @param stateAbbreviation the new state abbreviation
	 */
	public void setStateAbbreviation(String stateAbbreviation) {
		this.stateAbbreviation = stateAbbreviation;
	}

	public static State fromAbbr(String stateAbbr) {
		if (stateAbbr != null) {
			for (State state : State.values()) {
				if (stateAbbr.equals(state.stateAbbreviation)) {
					return state;
				}
			}	
		}
		return null;		
	}
	
	public static State fromName(String stateName) {
		if (stateName != null) {
			for (State state : State.values()) {
				if (stateName.equals(state.name)) {
					return state;
				}
			}	
		}
		return null;		
	}
}
